package monster.com.cvh.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import monster.com.cvh.R;
import monster.com.cvh.view.RoundImageView;

/**
 * @author: ASUS
 * @data: 2018/4/9
 * @function:
 */
public class FeedBackPicAdapter extends BaseItemDraggableAdapter<String, BaseViewHolder> {

    public FeedBackPicAdapter(@Nullable List<String> data) {
        super(R.layout.item_feed_back_pic, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, String item) {
        RoundImageView imageView = helper.getView(R.id.iv_item_feedback);

        Glide.with(mContext)
                .load(item)
                .into(imageView);

        //点击小叉删除当前图片，根据图片数量控制尾部添加icon显示还是隐藏
        helper.getView(R.id.iv_item_feedback_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int position = helper.getAdapterPosition();
                remove(position);
                if (mData.size() <= 2) {
                    getFooterLayout().setVisibility(View.VISIBLE);
                } else {
                    getFooterLayout().setVisibility(View.GONE);
                }
            }
        });
    }
}